package com.lc.luzhengtang.view.goodsdetail;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;



/**
 * Created by congl on 2017/6/30.
 */

public class NoticeBottomScrollView extends ScrollView {

    private static final String TAG = "NoticeBottomScrollView";

    private OnScrollToBottomListener listener;

    public interface OnScrollToBottomListener {
        void onScrollToBottom(boolean isBottom);
    }


    public NoticeBottomScrollView(Context context) {
        super(context);
        init();
    }

    public NoticeBottomScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public NoticeBottomScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {

    }

    public void setOnScrollToBottomListener(OnScrollToBottomListener listener) {
        this.listener = listener;
    }

    @Override
    protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) {
        super.onOverScrolled(scrollX, scrollY, clampedX, clampedY);
        if (listener != null) {
            listener.onScrollToBottom(scrollY == 0 && clampedY);
        }//        Log.d(TAG, "onOverScrolled:scrollX = " + scrollX + ",scrollY = " + scrollY + ",clampedX = " + clampedX + ",clampedY = " + clampedY);
    }
}
